< previous page page_61 next page >

Page 61
Up to this point, nothing is really being changed yet. You're giving users two choices when it comes to actually changing the colors:
The Apply button changes colors without closing the Color dialog box.
The Close button changes the colors and then closes the dialog box.
Also, a button on the form will reset the colors to the defaults for the user's computer. Using the Apply button allows users to see what the selected colors will look like before leaving the Color dialog box; if they don't like them, they can try different ones. To finish up the demo, add the following code to the frmColor code:
Private Sub cmdApply_Click()
    frmDialog!txtSourceFile.BackColor = lblTxtBack.BackColor
    frmDialog!txtTargetFile.BackColor = lblTxtBack.BackColor
    frmDialog.BackColor = lblAppBack.BackColor
End Sub

Private Sub cmdClose_Click()
    frmDialog!txtSourceFile.BackColor = lblTxtBack.BackColor
    frmDialog!txtTargetFile.BackColor = lblTxtBack.BackColor
    frmDialog.BackColor = lblAppBack.BackColor
    Unload Me
End Sub

Private Sub cmdReset_Click()
    lblTxtBack.BackColor = vbWindowBackground
    lblAppBack.BackColor = vbButtonFace
End Sub
In the cmdReset routine, constant values are used for the related Windows default colors. Try running the application one last time and see how this new form works.
Note
When you end the application, any changes you've made to the colors, fonts, or printer options are lost. You can use several different methods to save this information. Later in this book, you'll see how to save and retrieve information related to your application properties.

Don't forget to save this project, as you'll be coming back to it later today and later in the book.
Fonts
Setting up the Common Dialog control to work with fonts is just as easy as setting it up for the Open/Save As functions. In fact, as you've seen in the preceding example, you could use the same Common Dialog control on the form for all the different functions

 
< previous page page_61 next page >

If you like this book, buy it!